package com.app.service.impl;

import com.app.mapper.JobAdditionalMapper;
import com.app.mapper.JobPublishMapper;
import com.app.model.*;
import com.app.service.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;


/**
 * @Description:附加信息实现类
 * @Author: N
 * @Date: 2022年11月24日 10点29分
 */
@Service
public class JobAdditionalServiceImpl implements JobAdditionalService {
    @Autowired
    JobAdditionalMapper jobAdditionalMapper;

    @Override
    public void delete(int id) {
        HashMap<String, Object> objectObjectHashMap = new HashMap<>();
        objectObjectHashMap.put("cus_id",id);
        jobAdditionalMapper.deleteByMap(objectObjectHashMap);
    }

    @Override
    public int insert(JobAdditionalModel model) {
        return jobAdditionalMapper.insert(model);
    }

    @Override
    public JobAdditionalModel getModelByCid(int customerId) {
        QueryWrapper<JobAdditionalModel> queryWrapper = new QueryWrapper<>();
        queryWrapper.select().eq("cus_id",customerId);
        List<JobAdditionalModel> userList = jobAdditionalMapper.selectList(queryWrapper);
        if(userList!=null&&userList.size()>0)
        {
            return userList.get(0);
        }else {
            return null;
        }
    }
}
